import request from '@/utils/request'

// 查询商品类别列表
export function listCategory(query) {
  return request({
    url: '/category/category/list',
    method: 'get',
    params: query
  })
}

// 查询所有商品类别（不分页）
export function listAllCategory() {
  return request({
    url: '/category/category/list',
    method: 'get',
    params: { pageSize: 1000 }
  })
}

// 查询商品类别详细
export function getCategory(categoryId) {
  return request({
    url: '/category/category/' + categoryId,
    method: 'get'
  })
}

// 新增商品类别
export function addCategory(data) {
  return request({
    url: '/category/category',
    method: 'post',
    data: data
  })
}

// 修改商品类别
export function updateCategory(data) {
  return request({
    url: '/category/category',
    method: 'put',
    data: data
  })
}

// 删除商品类别
export function delCategory(categoryId) {
  return request({
    url: '/category/category/' + categoryId,
    method: 'delete'
  })
}

// 根据分类ID查询商品信息列表
export function getGoodsByCategoryId(categoryId) {
  return request({
    url: '/info/info/list',
    method: 'get',
    params: { parentId: categoryId }
  })
}

// 新增商品信息
export function addGoodsInfo(data) {
  return request({
    url: '/info/info',
    method: 'post',
    data: data
  })
}

// 修改商品信息
export function updateGoodsInfo(data) {
  return request({
    url: '/info/info',
    method: 'put',
    data: data
  })
}

// 获取商品信息详情
export function getGoodsInfo(id) {
  return request({
    url: '/info/info/' + id,
    method: 'get'
  })
}
